home *** CD-ROM | disk | FTP | other *** search
- Path: merle.acns.nwu.edu!judd
- From: judd@merle.acns.nwu.edu (Stephen Judd)
- Newsgroups: comp.sys.cbm
- Subject: Re: anyone doing heavy math on a c64?
- Date: 6 Feb 1996 03:09:52 GMT
- Organization: Northwestern University, Evanston IL
- Message-ID: <4f6gq0$q4l@news.acns.nwu.edu>
- References: <4e2l0q$n8f@turing.fwi.uva.nl> <4e84hu$13c@gatekeeper2.svl.trw.com> <4ej26o$qmr@news.acns.nwu.edu> <4f49t9$2q5@madeline.INS.CWRU.Edu>
- Reply-To: sjudd@nwu.edu (Stephen Judd)
- NNTP-Posting-Host: merle.acns.nwu.edu
-
- In article <4f49t9$2q5@madeline.INS.CWRU.Edu>,
- Anthony M. King <hw827@cleveland.Freenet.Edu> wrote:
- >
- >Try this on a 128 : print 23.13 - 22.87 hit RETURN
- >
- > Do you get .260000005?
- >
- >I get that everytime, is that the same result on every 128 or just
- >something messed up on mine?
-
- Sometimes numbers that are very nice in one base are nasty in
- another base. For instance, 1/3 is very easy to represent in
- base three, but cannot be exactly represented in base 10.
-
- As I'm sure you know, a number like 23.13 is 2*10^1 + 3*10^0 +
- 1*10^-1 + 3*10^-2.
-
- Let's represent a very simple number like 0.1 (i.e. 1/10) in base 2.
- The number will look like 0.00101001 or something, i.e. something
- times 2^-1, plus something times 2^-2, etc.:
- power result coefficient remainder (base 10)
- ----- ------ ----------- ---------
- -1 .5 0 .1
- -2 .25 0 .1
- -3 .125 0 .1
- -4 .0625 1 .1-0.0625 = 0.0375
- -5 .03125 1 .0375-0.03125 = .00625
- -6 .015625 0 .00625
- -7 .0078125 0 .00625
- -8 .00390625 1 .00625-.00390625=0.00234375
- -9 .001953125 1 .00234375-.001953125=.000390625
- -10 .0009765625 0
- -11 .00048828125 0
-
- etc.
-
- In short, 0.1 base ten is 0.00011001100110011001100... binary. Note
- that you will have the same problem on a Cray Y-MP, an HP
- workstation, etc. Your fingers are more accurate than a computer
- in this case.
-
- You can write custom routines to deal with this but then you will
- of course have problems with other numbers.
-
- >Can't do heavy math if the machine cant do simple subtraction accurately.
-
- "Can't" is a very strong contraction and I see it twice in the above
- sentence. And in a C64 newsgroup, too. For shame! Flog yourself
- with your keyboard in atonement.
-
- evetS-
-
- P.S. Martijn I will respond to your email in due time :)
-